function intoProxyList() {
	if (nowProjectIndex >= 0) {
		getProxyList(nowProjectIndex);
		listDivKind = "proxy";
		openListDiv();
	}
}

function cantIntoProxyList(){
	rat.pushInfo("这个项目没有开启代理功能！");
}

function getProxyList() {
	send("GET", "/@ServerProxy?" + nowProjectIndex, true, "", showProxyList, null);
}

function removeProxy(proxyIndex) {
	if (confirm("是否删除\n" + "代理[" + proxyIndex + "]")) {
		rat.qure();
		var json = {};
		json.projectIndex = nowProjectIndex;
		json.order = "Remove";
		json.proxyIndex = proxyIndex;
		send("POST", "/@ServerProxy", true, JSON.stringify(json), showProxyList, null);
	}
}

function addProxy() {
	var url = prompt("请输入新代理定位", "/NewProxyUrl");
	if (url != null) {
		var destinationAddress = prompt("请输入新代理地址", "www.newAddress.net");
		if (destinationAddress != null) {
			var port = prompt("请输入新代理端口", "80");
			if(port != null){
				rat.qure();
				var json = {};
				json.projectIndex = nowProjectIndex;
				json.order = "Add";
				json.url = url;
				json.destinationAddress = destinationAddress;
				destinationPort = JSON.parse(port);
				if(destinationPort==null||destinationPort==undefined){
					destinationPort = 80;
				}
				json.destinationPort = destinationPort;
				send("POST", "/@ServerProxy", true, JSON.stringify(json), showProxyList, null);
			}
		}
	}
}

function showProxyList(text) {
	var proxyList = JSON.parse(text);
	var html = "";
	for (let i = 0; i < proxyList.length; i++) {
		let proxy = proxyList[i];
		let url = proxy.url;
		let destinationAddress = proxy.destinationAddress;
		let destinationPort = proxy.destinationPort;
		html += "<lable>定位</lable>";
		html += "<input type=\"button\" name=\"proxyUrl\" class=\"proxyUrl\" value=\"";
		html += url;
		html += "\"/>";
		html += "<lable>目标</lable>";
		html += "<input type=\"button\" name=\"destination\" class=\"destination\" value=\"";
		html += destinationAddress+":"+destinationPort;
		html += "\"/>";
		html += "<button type=\"button\" class=\"remove\" onclick=\"removeProxy(" + i +
			")\">删</button>";
		html += "<br>";
	}
	html += "<br><button type=\"button\" class=\"show\" onclick=\"addProxy()\">添加</button>";
	document.getElementById("ListTitle").innerHTML = "代理列表";
	document.getElementById("ListContent").innerHTML = html;
}